package com.example.controller;

import com.example.entity.MedicalService;
import com.example.service.MedicalServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/medicalService")
public class MedicalServiceController {

    @Autowired
    private MedicalServiceService medicalServiceService;

    // 记录医疗服务
    @PostMapping("/add")
    public String addMedicalService(@RequestBody MedicalService medicalService) {
        medicalServiceService.addMedicalService(medicalService);
        return "医疗服务记录成功";
    }

    // 根据ID查询医疗服务
    @GetMapping("/get/{id}")
    public MedicalService getMedicalServiceById(@PathVariable int id) {
        return medicalServiceService.getMedicalServiceById(id);
    }

    @GetMapping("/getByInsuredPersonId/{insuredPersonId}")
    public List<MedicalService> getMedicalServicesByInsuredPersonId(@PathVariable int insuredPersonId) {
        return medicalServiceService.getMedicalServicesByInsuredPersonId(insuredPersonId);
    }


    // 查询所有医疗服务
    @GetMapping("/all")
    public List<MedicalService> getAllMedicalServices() {
        return medicalServiceService.getAllMedicalServices();
    }

    // 更新医疗服务
    @PutMapping("/update")
    public String updateMedicalService(@RequestBody MedicalService medicalService) {
        medicalServiceService.updateMedicalService(medicalService);
        return "医疗服务信息更新成功";
    }

    // 删除医疗服务
    @DeleteMapping("/delete/{id}")
    public String deleteMedicalService(@PathVariable int id) {
        medicalServiceService.deleteMedicalService(id);
        return "医疗服务删除成功";
    }
}
